<?php
/**
 * @name HookPlugin
 * @desc Yaf定义了如下的6个Hook,插件之间的执行顺序是先进先Call
 * @see http://www.php.net/manual/en/class.yaf-plugin-abstract.php
 * @author aLuckyfellow<136171154@qq.com>
 */
class HookPlugin extends Yaf_Plugin_Abstract
{

    public function routerStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {
        //增加伪静态 url后缀  默认为 " .api" 可在配置文件中修改
        if(Yaf_Registry::get('config')->application->url_suffix) {

            if(strtolower(substr($_SERVER['REQUEST_URI'], - strlen(Yaf_Registry::get('config')->application->url_suffix))) == strtolower(Yaf_Registry::get('config')->application->url_suffix)) {
                $request->setRequestUri(substr($_SERVER['REQUEST_URI'], 0 , - strlen(Yaf_Registry::get('config')->application->url_suffix)));
            }
        }
    }

    public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {

    }

    public function dispatchLoopStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {

    }

    public function preDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {

    }

    public function postDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {

    }

    public function dispatchLoopShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {

    }
}
